<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="author" content="zhupeng">
		<title>保证金退款</title>
		<script language="javascript" src="/script/common.js" type="text/javascript"></script>
		
		<script language="javascript" type="text/javascript">
		var creditUserId;
		function load(){
		Eui.showNavigation();
			setPages(["searchFormDiv","operationFormDiv"]);
		}
		function doWithdraw(){
			if(!checkForm("depositForm"))return;
			var amount = $("depositForm").amount.value;
			DWR.call('tradeService.cashWithdraw', creditUserId, amount * 100,AccountType.CREDIT,function(v){
				showInformation("保证金帐户退款成功！退款金额"+amount+"元.")
				switchPage("searchFormDiv");
				$("depositForm").reset();
			});
		}
		function checkData(){
			var orgId = $("searchForm").orgUniqueId.value;
			var creditId = $("searchForm").creditId.value;
			if(orgId || creditId){
				DWR.call('creditTxService.findCreditUser', orgId, creditId,function(v){
					var def = v.cardUser;
					creditUserId = def.uniqueId;
					def.orgName = v.creditOrg.name;
					def.orgUniqueId =v.creditOrg.uniqueId;
					def.orgLevel = Common.getText("org_level",v.creditOrg.orgLevel);
					if (v.accounts){
						var acc = v.accounts["user_"+AccountType.CREDIT]
						def.balance = Format.fenToYuan(acc.balance);
						def.lowLimit = Format.fenToYuan(Math.abs(acc.lowLimit));
					}
					Common.showDetail("operationFormDiv",def);
				
					switchPage("operationFormDiv");
					$("searchForm").reset();
				});
			}else{
				showWarning("机构编号和保证金帐户编号不能同时为空！")
			}
		}
		
		//选择机构方法
		function creditSelOrg(){
			SystemMgnt.selOrg(function(sorg) {
				$('searchForm').orgUniqueId.value = sorg.uniqueId;
			},{funcType : Constants.SELORG_ALL});
		}
		
		</script>
	</head>
	<body onload="load()">
		<div class="nav"><div id="nav">&nbsp;</div></div>
		<div id="searchFormDiv">
			<div class="form">
				<div class="formTitle">请输入要退款的帐户的相关信息</div>	
				<form id='searchForm' action="">
					<table cellSpacing="0" cellPadding="4" width="100%" border="0" align="center">
						<tr>
							<td>
								<label>机构编号</label> <input type="text" size="22" name="orgUniqueId" value=""  maxlength="20"><a class="orga" href="#" onclick="creditSelOrg();">&nbsp;&nbsp;</a>
							</td>
							<td>
								<label>保证金账号</label> 
								<input type="text" size="22" name="creditId" value="" maxlength="20" >
							</td>
							<td><button type="button" onclick="checkData()">查  询</button></td>
						</tr>
					</table>
				</form>	
			</div>
		</div>
		
		<div id="operationFormDiv" style="display:none;" >
			<div class="form">
				<div class="formTitle">帐户明细</div>	
				<form id="operationForm" action="">
					<table cellSpacing="0" cellPadding="4" width="100%" border="0" class="viewTable" class="col2 label5">
						<tr>
							<td><label>机构名称</label> <span id="orgName" ></span></td>
							<td><label>机构编号</label> <span id="orgUniqueId" ></span></td>
						</tr>
						<tr>
							<td><label>等&nbsp;&nbsp;&nbsp;&nbsp;级</label> <span id="orgLevel" ></span></td>
							<td><label>帐号编号</label><span id="uniqueId"></span></td>
						</tr>
						<tr>
							<td><label>余&nbsp;&nbsp;&nbsp;&nbsp;额</label> <span id="balance" ></span></td>
							<td><label>透支额度</label><span id="lowLimit"></span></td>
						</tr>
					</table>
				</form>
			</div>
			
			<div class="form">
				<div class="formTitle">保证金退款</div>	
				<form id="depositForm" action="">
					<table cellSpacing="0" cellPadding="4" width="100%" border="0" class="viewTable" class="col2 label5">
						<tr>
							<td><label>退款金额</label> <input type="text" name="amount" onblur="checkV(this,'nonNegativeAmount',true)"><span class="des">*</span></td>
							<td>&nbsp;</td>
						</tr>
						
					</table>
				</form>
			</div>
			<p>
				<button type="button" onclick="doWithdraw()">确 定</button>
				<button type="button" onclick="switchPage('searchFormDiv')">返 回</button>
			</p>
		</div>
			
	</body>
</html>